package com.xlf.service.judge.config;

import com.xlf.service.judge.io.LanguageConfigLoader;
import com.xlf.service.judge.io.impl.DefaultResourceLoader;
import com.xlf.service.judge.io.ResourceLoader;
import com.xlf.service.judge.io.impl.YmlLanguageConfigLoader;
import com.xlf.service.judge.strategy.judgeMachine.AbstractJudgeMachineStrategy;
import com.xlf.service.judge.strategy.judgeMachine.impl.goJudge.GoJudgeMachine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author xlf 2734029211@qq.com
 * @Date 2023/9/18 17:03
 * @Description: 判题机配置
 * @Version 1.0
 */
@Configuration
public class JudgeMachineConfig {

    @Autowired
    JudgeConfig judgeConfig;

    @Bean
    public LanguageConfigLoader languageConfigLoader(){
        return new YmlLanguageConfigLoader();
    }

    @Bean
    public ResourceLoader resourceLoader(){
        return new DefaultResourceLoader();
    }

    @Bean
    public AbstractJudgeMachineStrategy goJudge(LanguageConfigLoader languageConfigLoader, ResourceLoader resourceLoader){

        GoJudgeMachine goJudge = new GoJudgeMachine(languageConfigLoader,resourceLoader);
        goJudge.setUrl(judgeConfig.getUrl());
        return goJudge;
    }

//    @Bean
//    public AbstractJudgeMachineStrategy localJudge(LanguageConfigLoader languageConfigLoader, ResourceLoader resourceLoader){
//        AbstractJudgeMachineStrategy localJudge = new LocalJudgeMachine(languageConfigLoader,resourceLoader);
//        return localJudge;
//    }
}
